package demo.exception.home;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * @author yulian174
 * @version 1.0
 */
public class Homework01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入两个参数：");
        try {
            int a = sc.nextInt();
            int b = sc.nextInt();
            double c = call(a, b);
            System.out.println(c);
        } catch (NumberFormatException e) {
            System.out.println("格式不正确");
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("缺少命令行参数");
        } catch (ArithmeticException e) {
            System.out.println("被除数为0");
        } catch (InputMismatchException e) {
            System.out.println("输入格式与预期类型不符");
        } finally {
            System.out.println("异常处理结束");
        }
    }

    public static double call(int n1, int n2) {
        return n1 * 1.0 / n2;
    }
}
